<template>
  <div class="box">
    <div class="hold">
      <div v-if="showLoading" class="box-center">
        <atom-loading />
      </div>
      <!-- 此次取全量 -->
      <template v-else>
        <holding-list
          :stockList="dataList"
          :cardList="dataCard"
          :isView="true"
          :isTrackPool="isTrackPool"
          offsetList="14.4vw"
        ></holding-list>
        <div class="no-more">
          <span>没有更多了~</span>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
import mixins from '@/views/detail/mixins';
import HoldingList from '@/components/detail/HoldingList.vue';
import tools from '@/lib/tools';

export default {
  mixins: [mixins],
  components: {
    HoldingList,
  },
  data() {
    return {
      showLoading: false,
      isTrackPool: false,
      dataCard: [],
    };
  },
  async created() {
    tools.setTitle('持仓记录');
    const gpcId = window.getParam('gpc_id');
    this.isTrackPool = !!window.getParam('isTrackPool');
    if (gpcId) {
      this.showLoading = true;
      const list = this.isTrackPool
        ? await this.getTackPool(gpcId)
        : await this.getSelectedPool(gpcId);
      if (!list.length) {
        this.dataList = [];
        this.showLoading = false;
        return;
      }
      await this.handleDataList(list);
      await this.getSignalList();
      const arr = Object.values(this.cardMap);
      const allArr = [];
      for (const item of arr) {
        allArr.push(...Object.values(item));
      }
      this.dataCard.push(...allArr);
      this.showLoading = false;
    } else {
      this.dataList = [];
      this.dataCard = [];
    }
  },
};
</script>

<style lang="less" scoped>
.box {
  background: var(--bg-color-1);
  padding: 8px 6px;
  .hold {
    padding: 10px;
    background: var(--bg-color-2);
    border-radius: 6px;
    min-height: 708px;
    position: relative;
    .box-center {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  .no-more {
    font-size: 14px;
    line-height: 18px;
    margin-top: 16px;
    color: var(--text-3);
    display: flex;
    justify-content: center;
  }
}
</style>
